<template>
    <div class="userCenter">
        <div class="breadcrumb-box">
            <el-breadcrumb separator-class="el-icon-arrow-right">
                <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
                <el-breadcrumb-item>个人中心</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="center container td-f">
            <left-nav-bar :active="active"></left-nav-bar>
            <div class="right">
                <div class="ti-top" v-if="loading">
                    <div class="right-top">
                        <router-link :to="`/setting`" class="left-ava" v-if="userInfo.avatar">
                            <img :src="userInfo.avatar" alt="" />
                        </router-link>
                        <!-- <router-link :to="`/setting`" class="detaiult-avatar td-fcc" v-else>
                            <img src="../../assets/svg/svg_avatar.svg" alt="" />
                        </router-link> -->
                        <router-link :to="`/setting`" class="right-txt">
                            <div v-show="userInfo.nickname">{{userInfo.nickname}}</div>
                            <div class="td-fcc" v-if="userInfo.company_name">{{userInfo.company_name}}</div>
                        </router-link>
                    </div>
                    <div class="right-list">
                        <div class="li" @click="changeOrder(0)">
                            <div v-show="orderStatusNum.unshipped_count">{{orderStatusNum.unshipped_count}}</div>
                            <img src="../../assets/svg/svg_dfh.svg" alt="" />
                            <div>待发货</div>
                        </div>
                        <div class="li" @click="changeOrder(1)">
                            <div v-show="orderStatusNum.received_count">{{orderStatusNum.received_count}}</div>
                            <img src="../../assets/svg/svg_dsh.svg" alt="" />
                            <div>待收货</div>
                        </div>
                        <div class="li" @click="changeOrder(2)">
                            <div v-show="orderStatusNum.evaluated_count">{{orderStatusNum.evaluated_count}}</div>
                            <img src="../../assets/svg/svg_dpj.png" alt="" />
                            <div>已完成</div>
                        </div>
                        <!-- <div class="li" @click="$router.push('/order/?type=-3')">
                            <div v-show="orderStatusNum.refund_count">{{orderStatusNum.refund_count}}</div>
                            <img src="../../assets/svg/svg_sh.svg" alt=""/>
                            <div>售后</div>
                        </div> -->
                    </div>
                </div>
             
                <div class="order" v-for="(item,index) in orderList" :key="index">
                    <img :src="item.cartInfo[0].productInfo.image" class="order-l" alt="">
                    <div class="order-r">
                        <div class="order-t">
                            <div class="order-tit">{{item.cartInfo[0].productInfo.store_name}}</div>
                            <div class="order-express">普通快递</div>
                            <div class="line1"></div>
                            <div class="order-date">2020-08-21 16:54:33</div>
                        </div>
                        <div class="order-b">
                            <div class="order-b-l">
                                <div class="order-b-l-top">
                                    <div class="price">￥128.00</div>
                                    <div class="choise">规格：白色 / 6200</div>
                                    <div class="num">× 10</div>
                                </div>
                                <div class="remark">备注：确保质量，保证快递过程中完好无损。</div>
                            </div>

                            <div class="order-b-r">
                                <div class="look-detail" @click="navDetail(item.id)">查看详情</div>
                                <div class="grayline"></div>
                                <div class="contact" @click.stop="$refs.contact.contactShow = true">联系客服</div>
                            </div>
                        </div>
                    </div>
                </div>
                 <div class="nodata" v-if="orderList.length == 0">
                    <img :src="$global.Image.noCollection" />
                </div>
            </div>
        </div>
        <div style="height: 200px"></div>
        <contact ref="contact"></contact>
    </div>
</template>

<script>
import contact from '@/components/contact';
import leftNavBar from "@components/leftNavBar";
import { getUser, getMyMessage, searchQuota } from "@api/user";
import {getOrderListPc} from '@api/order';
export default {
    name: "userCenter",
    data() {
        return {
            loading: false,
            active: 1,
            userInfo: {},
            messageList: [],
            quotaInfo: "",
            status:0,
            orderList:[],
            orderStatusNum: {},
        };
    },
    components: {
        leftNavBar,
        contact
    },
    methods: {
        navDetail(id){
            this.$router.push({
                path:"/orderDetails",
                query:{
                    id:id
                }
            })
        },
        changeOrder(index){
            this.status = index;
        },
        User() {
            let that = this;
            getUser().then((res) => {
                that.userInfo = res.data;

                that.orderStatusNum = res.data.orderStatusNum;
            });
        },
        getList(){
            getOrderListPc({page:1,limit:5}).then(res=>{
                console.log(res)
                this.orderList = res.data.list;
            }).catch(err=>{
                console.log(err)
            })
        },
        searchQuota() {
            let params = {
                name: 123,
            };
            searchQuota(params).then((res) => {
                this.quotaInfo = res.data;
            });
        },
        getMessage() {
            getMyMessage(this.where).then(
                (res) => {
                    // that.loaded = res.data.length < that.where.limit;
                    // that.where.page = that.where.page + 1;
                    this.loading = true;
                    this.messageList.push.apply(this.messageList, res.data);
                },
                (error) => {
                    this.$dialog.message(error.msg);
                }
            );
        },
        goOrderList(index) {
            this.$router.push("/order?type=" + index);
        },
    },
    mounted() {
        this.User();
        this.getMessage();
        this.searchQuota();
        this.getList()
    },
};
</script>

<style scoped  rel="stylesheet/scss" lang="scss" scoped>
$color: #da213d;
.userCenter {
    width: 100%;
    height: 100%;

    .center {
        /*width: 70%;*/
        margin: 0 auto;
        display: flex;

        .right {
            width: 1000px;
            margin-left: 32px;
            /*margin-top: 90px;*/
            .order {
                display: flex;
                border: 1px solid #efc2c1;
                padding: 30px 20px;
                box-sizing: border-box;
                margin-top: 10px;
                .order-l {
                    width: 120px;
                    height: 120px;
                }
                .order-r {
                    margin-left: 20px;
                    .order-t {
                        display: flex;
                        .order-tit {
                            font-size: 18px;
                            font-weight: bold;
                            text-align: left;
                            color: #333333;
                            line-height: 24px;
                            flex: 1;
                        }
                        .order-express {
                            margin-left: 67px;
                            font-size: 16px;
                            color: rgb(51, 51, 51);
                            line-height: 21px;
                        }
                        .line1 {
                            background: #333333;
                            margin: 3px 20px;
                            width: 2px;
                            height: 15px;
                        }
                        .order-date {
                            font-size: 16px;
                            color: #333333;
                            line-height: 21px;
                        }
                    }
                    .order-b {
                        display: flex;
                        align-items: center;
                        .order-b-l {
                            flex: 1;
                            .order-b-l-top {
                                margin-top: 10px;
                                display: flex;
                                align-items: center;
                                .price {
                                    font-size: 20px;
                                    font-weight: 500;
                                    color: #da213d;
                                    margin-right: 23px;
                                }
                                .choise {
                                    font-size: 14px;
                                    color: #666666;
                                    margin-right: 61px;
                                }
                                .num {
                                    font-size: 14px;
                                    color: #666666;
                                }
                            }
                            .remark {
                                margin-top: 15px;
                                font-size: 12px;
                                color: #666666;
                            }
                        }
                        .order-b-r {
                            display: flex;
                            align-items: center;
                            .look-detail {
                                font-size: 18px;
                                color: #333333;
                                cursor: pointer;
                            }
                            .grayline {
                                width: 2px;
                                height: 20px;
                                background: #ecdfdd;
                                border-radius: 1px;
                                margin: 0 20px;
                            }
                            .contact {
                                font-size: 18px;
                                cursor: pointer;
                                color: #333333;
                            }
                        }
                    }
                }
            }
            .ti-top {
                border: 1px solid #efc2c1;
                border-top-left-radius: 5px;
                border-top-right-radius: 5px;
                .right-top {
                    display: flex;
                    height: 160px;
                    align-items: center;
                    background: url("../../assets/second_icon/center_bg.png")
                        no-repeat;
                    background-size: 100% 100%;
                    position: relative;

                    .left-ava {
                        margin-left: 55px;
                        width: 82px;
                        height: 82px;
                        border-radius: 50%;
                        display: flex;
                        justify-content: center;
                        align-items: center;
                        background-color: #fff;
                        box-shadow: inset 0 0 5px 1px
                            rgba($color: #000000, $alpha: 0.2);
                        img {
                            width: 74px;
                            height: 74px;
                            border-radius: 50%;
                        }
                    }
                    .detaiult-avatar {
                        margin-left: 55px;
                        width: 99px;
                        height: 99px;
                        border-radius: 50%;
                        background-color: #fff;
                        box-shadow: inset 0 0 5px 1px
                            rgba($color: #000000, $alpha: 0.2);
                        img {
                            width: 66px;
                            height: 66px;
                            margin-left: 10px;
                        }
                    }

                    .right-txt {
                        display: flex;
                        height: 99px;
                        justify-content: center;
                        align-items: center;
                        margin-left: 5px;

                        > div:nth-of-type(1) {
                            color: #ffffff;
                            font-size: 20px;
                            margin-left: 20px;
                            text-align: justify;
                        }

                        > div:nth-of-type(2) {
                            height: 32px;
                            line-height: 32px;
                            padding: 0 20px;
                            text-align: center;
                            margin-left: 20px;
                            background: linear-gradient(
                                270deg,
                                rgba(23, 22, 20, 0.3) 1%,
                                rgba(99, 77, 77, 0.3)
                            );
                            border-radius: 15px;
                            color: rgba(255, 255, 255, 1);
                            font-size: 18px;
                            // margin-top: 19px;
                            small {
                                padding-right: 2px;
                            }
                        }
                    }

                    .set-btn {
                        position: absolute;
                        right: 30px;
                        top: 50%;
                        width: 70px;
                        height: 30px;
                        font-size: 16px;
                        color: #fff;
                        cursor: pointer;
                        border-radius: 8px;
                        border: 1px solid #da213d;
                        background: #da213d;
                        transform: translateY(-50%);
                        transition: all 0.3s;
                    }

                    .set-btn:hover {
                        background: #fff;
                        color: #da213d;
                    }
                }

                .right-list {
                    display: flex;
                    height: 130px;
                    width: 100%;
                    align-items: center;
                    justify-content: space-around;
                    // margin: 0 auto;
                    cursor: pointer;

                    .li {
                        display: flex;
                        flex-direction: column;
                        width: 33.3%;
                        justify-content: center;
                        align-items: center;
                        position: relative;
                        &::before {
                            position: absolute;
                            right: 0;
                            top: 0;
                            bottom: 0;
                            margin: auto 0;
                            content: "";
                            width: 2px;
                            height: 47px;
                            background: #ecdfdd;
                            border-radius: 1px;
                        }
                        > div:nth-of-type(1) {
                            min-width: 25px;
                            height: 25px;
                            line-height: 25px;
                            text-align: center;
                            background-color: $color;
                            color: #ffffff;
                            font-size: 15px;
                            position: absolute;
                            z-index: 2;
                            border-radius: 50%;
                            margin: -40px 0 0 30px;
                        }

                        img {
                            width: 50px;
                            height: 41px;
                            object-fit: contain;
                        }

                        div:nth-of-type(2) {
                            color: rgba(102, 102, 102, 1);
                            font-size: 17px;
                            font-family: MicrosoftYaHei;
                            margin-top: 13px;
                        }
                    }

                    .li:last-child {
                        img {
                            max-width: 54px;
                        }
                        &::before {
                            display: none;
                        }
                    }
                }
            }

            .line-ti {
                width: 100%;
                border-bottom: 3px solid #dbdbdb;
                margin-top: 50px;
                height: 40px;
                > div {
                    color: rgba(61, 117, 175, 1);
                    font-size: 18px;
                    font-family: MicrosoftYaHei-Bold;
                    border-bottom: 3px solid $color;
                    width: 72px;
                    height: 40px;
                    line-height: 36px;
                    padding-left: 18px;
                }
            }

            .shop-list {
                .shop-li {
                    padding-bottom: 10px;

                    .top {
                        display: flex;
                        align-content: center;
                        justify-content: space-between;
                        margin: 30px 0 16px 0;

                        .le {
                            display: flex;
                            height: 24px;
                            align-items: center;

                            img {
                                width: 18px;
                                height: 16px;
                            }

                            > div {
                                color: rgba(51, 51, 51, 1);
                                font-size: 17px;
                                font-family: MicrosoftYaHei;
                                padding-left: 12px;
                            }
                        }

                        .ri {
                            > div {
                                color: #999999;
                            }
                        }
                    }

                    .bot {
                        width: 100%;
                        height: 40px;
                        display: flex;
                        justify-content: space-between;
                        align-items: center;

                        .l {
                            display: flex;
                            height: 80px;
                            align-items: center;
                            margin-left: 15px;

                            img {
                                width: 80px;
                                height: 80px;
                            }

                            > div {
                                color: #333333;
                                padding-left: 15px;
                                font-size: 16px;
                                font-weight: 500;
                                width: 500px;
                                overflow: hidden;
                                text-overflow: ellipsis;
                                white-space: nowrap;
                            }
                        }

                        .r {
                            width: 85px;
                            height: 30px;
                            line-height: 30px;
                            text-align: center;
                            background: $color;
                            color: #3d75af;
                            font-size: 14px;
                            margin-right: 15px;
                            border-radius: 2px;
                            cursor: pointer;
                        }
                    }
                }

                .shop-li:not(:last-child) {
                    border-bottom: 1px solid #dbdbdb;
                }
            }
        }
    }
}
</style>
